#include <gtk/gtk.h>
int main(int argc, char *argv[])
{
    GtkWidget *window; //指向窗口的指针
    GtkWidget *table;
    GtkWidget *label1;
    GtkWidget *label2;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *button1;
    GtkWidget *button2;
    gtk_init(&argc, &argv);                       //初始化图形显示环境
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL); //新建窗口
    gtk_window_set_title(GTK_WINDOW(window), "Login");
    g_locale_to_utf8("用户登录", -1, NULL, NULL, NULL);
    table = gtk_tabel_new(3, 2, FALSE);
    label1 = gtk_label_new(g_locale_to_utf8("用户名", -1, NULL, NULL, NULL));
    //新建“用户名”标签
    gtk_widget_set_size_request(label1, 38, 15);
    label2 = gtk_label_new(g_locale_to_utf8("密码", -1, NULL, NULL, NULL));
    //新建“密码”标签
    gtk_widget_set_size_request(label2, 30, 15);
    entry1 = gtk_entry_new();
    entry2 = gtk_entry_new();
    button1 = gtk_button_new_with_label(g_locale_to_utf8("取消", -1, NULL, NULL, NULL));
    button2 = gtk_button_new_with_label(g_locale_to_utf8("确定", -1, NULL, NULL, NULL));
    //新建“确定”按钮
    gtk_container_add(GTK_CONTAINER(window), table);
    //下面将6个元件分别添加到表格相应的位置中
    gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1, (GtkAttachOptions)(0), GtkAttachOptions(0), 20, 10);
    gtk_table_attach(GTK_TABLE(table), entry1, 1, 2, 0, 1, (GtkAttachOptions)(0), GtkAttachOptions(0), 10, 10);
    gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 0, 1, (GtkAttachOptions)(0), GtkAttachOptions(0), 20, 10);
    gtk_table_attach(GTK_TABLE(table), entry2, 0, 1, 0, 1, (GtkAttachOptions)(0), GtkAttachOptions(0), 10, 10);
    gtk_table_attach(GTK_TABLE(table), button1, 0, 1, 0, 1, (GtkAttachOptions)(0), GtkAttachOptions(0), 20, 10);
    gtk_table_attach(GTK_TABLE(table), button2, 0, 1, 0, 1, (GtkAttachOptions)(0), GtkAttachOptions(0), 10, 10);
    gtk_widget_show(window);
    gtk_widget_show(table);
    gtk_widget_show(label1);
    gtk_widget_show(label2);
    gtk_widget_show(entry1);
    gtk_widget_show(entry2);
    gtk_widget_show(button1);
    gtk_widget_show(button2);
    gtk_main();
    return 0;
}